#pragma once
// ACEdit.h : Header-Datei
//

/*********************************************************************
*
* CACEdit
* Copyright (c) 2003 by Andreas Kapust
* All rights reserved.
* info@akinstaller.de
*
*********************************************************************/


#define _MODE_ONLY_FILES		(1L << 16)
#define _MODE_ONLY_DIRS			(1L << 17)

#define _MODE_STANDARD_			(1L << 0)
#define _MODE_SEPARATION_		(1L << 1)
#define _MODE_FILESYSTEM_		(1L << 2)
#define _MODE_FS_START_DIR_		(1L << 3)
#define _MODE_CURSOR_O_LIST_	(1L << 4)
#define _MODE_FIND_ALL_			(1L << 5)

#define _MODE_FS_ONLY_FILE_	(_MODE_FILESYSTEM_|_MODE_ONLY_FILES)
#define _MODE_FS_ONLY_DIR_	(_MODE_FILESYSTEM_|_MODE_ONLY_DIRS)
#define _MODE_SD_ONLY_FILE_	(_MODE_FS_START_DIR_|_MODE_ONLY_FILES)
#define _MODE_SD_ONLY_DIR_	(_MODE_FS_START_DIR_|_MODE_ONLY_DIRS)  //Fix 1.2

/////////////////////////////////////////////////////////////////////////////
// Fenster CACEdit 
#include "ACListWnd.h"


class CACEdit : public CWnd //CEdit
{
	// construction
public:
	CACEdit();
	void SetMode( INT iMode=_MODE_STANDARD_ );
	void SetSeparator(LPCTSTR lpszString,TCHAR lpszPrefixChar = 0)
	{
		m_SeparationStr = lpszString;
		m_Liste.m_PrefixChar = m_PrefixChar = lpszPrefixChar;
		SetMode(_MODE_SEPARATION_);
	}

	// CComboBox
	INT AddString( LPCTSTR lpszString);
	// added 02-03-2009
	INT UpdateList();
	INT GetLBText( INT nIndex, LPTSTR lpszText );
	void GetLBText( INT nIndex, CString& rString );
	INT SetDroppedWidth(UINT nWidth);
	INT FindString( INT nStartAfter, LPCTSTR lpszString );
	INT SelectString( INT nStartAfter, LPCTSTR lpszString );
	void ShowDropDown(BOOL bShowIt = TRUE );
	void ResetContent();
	INT GetCurSel();
	// added 02-03-2009
	INT SetCurSel(INT nSelect);

	// added 07-26-2005
	INT GetCount();
	INT FindStringExact( INT nIndexStart, LPCTSTR lpszFind );
	INT InsertString( INT nIndex, LPCTSTR lpszString );
	INT DeleteString( UINT nIndex );
	INT InsertItem( const COMBOBOXEXITEM* pCBItem );
	INT DeleteItem( INT iIndex );
	// added 08-08-2006
	BOOL SetReadOnly( BOOL bReadOnly = TRUE );
	// added 09-11-2006
	void SetSelection(INT nStartChar, INT nEndChar = -1, BOOL bNoScroll = FALSE );
	// added 10-20-2014
	INT SetItemData(INT nIndex, DWORD_PTR dwItemData);
	DWORD_PTR GetItemData(INT nIndex);

	// Attribute
public:
	void Init();
	void AddSearchString(LPCTSTR lpszString);
	void AddSearchStrings(LPCTSTR Strings[]);
	void RemoveSearchAll();
	void SetStartDirectory(LPCTSTR lpszString);
	// Operationen
public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);

	// Implementation
public:
	virtual ~CACEdit();
	CACListWnd m_Liste;

protected:
	CString m_EditText, m_SeparationStr,m_LastDirectory;
	TCHAR m_PrefixChar;
	INT m_iMode;
	afx_msg void OnKillfocus();
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnChange();
	afx_msg void OnCloseList();
	afx_msg LRESULT OnUpdateFromList(WPARAM wParam, LPARAM lParam);

	DECLARE_MESSAGE_MAP()

	void ReadDirectory(CString m_Dir);
	INT FindSepLeftPos(INT pos, BOOL FindSepLeftPos = FALSE);
	INT FindSepLeftPos2(INT pos);
	INT FindSepRightPos(INT pos);
	BOOL HandleKey(UINT nChar, BOOL m_bFromChild, UINT nFlags = NULL);

	BOOL m_CursorMode;
	INT m_iType;
	CEdit *m_pEdit;

	TCHAR m_szDrive[_MAX_DRIVE], m_szDir[_MAX_DIR],m_szFname[_MAX_FNAME], m_szExt[_MAX_EXT];
};

/////////////////////////////////////////////////////////////////////////////
